import { Button, Form, Input, Space, DatePicker, Select } from "antd";
import React from "react";
import { SearchOutlined } from "@ant-design/icons";
import _ from 'lodash'
import { getDateTime3 } from '@/utils/getDate'
import TheButton from '@/components/TheButton'

const { RangePicker } = DatePicker;

class SearchHeader extends React.Component {
  state = {
    options: []
  }
  onFinish = values => {
    if (values.time && values.time.length) {
      values.createTimeStart = getDateTime3(values.time[0])
      values.createTimeEnd = getDateTime3(values.time[1])
    }
    delete (values.time)
    _.forIn(values, (v, k) => {
      if (!v) {
        delete (values[k])
      }
    })
    this.props.getValue(values)
  }
  reset = () => {
    this.formRef.setFieldsValue({
      activityName: '',
    })
    this.props.getValue({})
  };
  render() {
    return (
      <div className="search-header search-header-list">
        <Form layout={'inline'} ref={ref => this.formRef = ref} onFinish={this.onFinish}>
          <Form.Item name={"activityName"}>
            <Input style={{ width: 500 }} suffix={<SearchOutlined />} placeholder={"活动名称"} />
          </Form.Item>
          <Form.Item>
            <Space size="small" style={{ marginLeft: 10 }}>
              <Button type="primary" htmlType="submit">
                查询
              </Button>
              <Button onClick={this.reset}>重置</Button>
            </Space>
          </Form.Item>
        </Form>
        <div>
        <TheButton size="middle" type="default"    hasPermi={['activitycode:list:addQrCode']}  onClick={this.props.toAdd}>新增二维码</TheButton>
        <TheButton size="middle" type="default"  hasPermi={['activitycode:list:batchDownQrCode']} onClick={this.props.toDownload}>批量下载</TheButton>
        <TheButton size="middle" type="default"   hasPermi={['activitycode:list:exportBatch']}  onClick={this.props.exportAll}>批量导出</TheButton>
        </div>

      </div>
    );
  }
}

export default SearchHeader;
